<template>
  <div class="header">
    <div class="title">
      <h1>文件管理系统</h1>
    </div>
    <div style="position: absolute; right: 20px; top: 50px; display: flex">

      <div class="custom-button" @click="showTimeDialog">
        <div>
          <span class="my-text">上传文件</span>
        </div>
      </div>
    </div>
    <el-dialog v-model="dialogVisible" title="密码验证" style="background-color: #383838">
      <el-row :gutter="20" style="display: flex;align-items: center;justify-content: center;">
        <el-form :model="form" label-width="auto">
          <el-form-item label="密码">
            <el-input v-model="form.password" />
          </el-form-item>
        </el-form>
      </el-row>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="onSubmit">确定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, onBeforeUnmount, watch, reactive, computed } from "vue";
import type { ComponentSize } from 'element-plus'
//导入socket
import { useStoreTemplate } from "@store/template";
const store = useStoreTemplate(); // 创建 store 实例
import { status, data, send, open } from "@renderer/utils/websocket";
import { getLocalIpApi } from "@renderer/api/face";
import { updateSetting, getSetting, cleanFace, getUnqualifiedFaces } from "@renderer/api/setting";
import { useRouter } from "vue-router"; // 添加这一行以导入 useRouter
import { ElNotification } from "element-plus";
const router = useRouter();
const isPaused = ref(false); // 状态变量，控制动画
const dialogVisible = ref(false);
const form = reactive({
  password: ''
})
const password = ref('abzy2024')

function goHome() {
  router.push("/");
}

function showTimeDialog() {
  dialogVisible.value = true;
}

const treeProps = {
  children: 'children',
  label: 'label'
}
function onSubmit() {
  // 在这里处理表单提交逻辑
  if (form.password === password.value) {
    dialogVisible.value = false;
    ElNotification.success('密码验证成功')
    router.push("/train")

  } else {
    ElNotification.error('密码验证失败')
  }
}
// 上传处理函数
const handleSuccess = (response) => {
  ElNotification.success('上传成功')
}

const handleError = (error) => {
  ElNotification.error('上传失败')
}

onMounted(() => {
});
onBeforeUnmount(() => {
});
</script>

<style scoped lang="scss">
@import "./css/my-header.scss";
</style>
